/*
 * @Author: zhangyang
 * @Date: 2022-03-01 14:03:04
 * @LastEditTime: 2022-03-14 11:00:18
 * @Description: 部分类型定义
 */
import type { App } from 'vue';
import type { Icons } from './icons';

export type UserModule = (ctx: App, ...args: any[]) => void;
export type LoginType = 'code' | 'scan';
export type Cbk = () => void;

export enum Params {
  com = 10000
};

export enum Status {
  TOKEN_NO_USE = -1,
  OK = 0
};

export type ResponseObj = {
  status: number;
  data: any;
  msg: string;
};

export type UserKey = {
  aid: number;
  token: string;
};

export type UserInfo = {
  admin_name: string;
  real_name: string;
  autoid: number;
  is_enable: 0 | 1,
  tel: string;
  role_id: number[];
  role_name: string[];
};



export type NavArrItem = {
  /**
   * 节点唯一 id，自增
   */
  autoid: number;
  /**
   * 是否节点显示
   * 0-不显示，1-显示
   */
  is_show: 0 | 1;
  /**
   * 节点描述
   */
  node_desc: string;
  /**
   * 节点名称
   */
  node_name: string;
  /**
   * 节点路径
   */
  node_path: string;
  /**
   * 节点排序标志
   */
  node_sort: number;
  /**
   * 节点层级
   */
  node_type: number;
  /**
   * 此节点父节点的唯一 id
   */
  parent_id: number;
  /**
   * 此节点下的子节点
   */
  part?: NavArrItem[] | [];
  /**
   * 图标名称
   */
  icon_name?: keyof typeof Icons;
  icon?: any;
} & Record<string, any>;

export type AddNodeItem = {
  autoid?: number;
  node_id?: number;
  node_name: string;
  node_desc: string;
  node_path: string;
  node_sort: number;
  is_show: number;
  parent_id: number;
  node_type: number;
};

export type EditNodeItem = {
  autoid: number;
  node_id: number;
  icon_name: keyof typeof Icons | '';
} & AddNodeItem;

export type Role = {
  autoid: number;
  is_enable: number;
  parent_role_id: number;
  role_desc: string;
  role_name: string;
  role_access: string;
};

export type AdminUser = {
  autoid: number;
  account: string;
  real_name: string;
  tel: string;
  role: string;
  is_enable?: 0 | 1;
  password?: string;
  last_time?: number;
  last_ip?: string;
};

export type EnableWrite<T extends any> = {
  -readonly [p in keyof T]: T[p];
};

export interface BaseQuery {
  page: number;
  limit: number;
  total: number;
};